ποΈGitΠ―ΡΠ°ποΈ
docs/en/developer/testing.md f17c38bf64dcd629641d1e310876871a2f8bfdac (f17c38bf) Text, 2.58 KB
---
title: Testing
parent: Developer Guide
nav_order: 7
last_updated: 2026-05-13
aliases:
Tff7b72- tests
Tff7b72- unit-tests
Tc9d1d9 - screenshot-tests
Tc9d1d9---
Tc9d1d9# Testing
Testing strategy and practices for the Meshtastic KMP project.
Tc9d1d9## Test Categories
Tc9d1d9### KMP Unit Tests (`commonTest`)
Shared tests that run on all platforms:
Ta5d6ff```Ta5d6ffbash
./gradlew allTests
Ta5d6ff```
Tff7b72- Business logic tests
Tff7b72- Data model validation
Tff7b72- Search/ranking algorithm tests
Tff7b72- Route serialization tests
Tc9d1d9### Android Host Tests
Android-specific tests that run on JVM:
Ta5d6ff```Ta5d6ffbash
./gradlew Tffa657test
Ta5d6ff```
Tff7b72- ViewModel tests
Tff7b72- Repository tests with Room fakes
Tff7b72- Android-specific integration tests
Tc9d1d9### Compose UI Tests
Compose Multiplatform UI test framework:
Ta5d6ff```Ta5d6ffkotlin
Tf0883e@Test
Tff7b72fun Td2a8ffmyScreenTestTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3runComposeUiTest Tb4b4b4{
Te6edf3setContent Tb4b4b4{ Te6edf3MyScreenTb4b4b4(Tb4b4b4) Tb4b4b4}
Te6edf3onNodeWithTextTb4b4b4(Ta5d6ff"Ta5d6ffExpectedTa5d6ff"Tb4b4b4)Tb4b4b4.Te6edf3assertIsDisplayedTb4b4b4(Tb4b4b4)
Tb4b4b4}
Ta5d6ff```
Located in Ta5d6ff`commonTest` or Ta5d6ff`jvmTest` source sets.
Tc9d1d9### Screenshot Tests
Uses Android Gradle Plugin's native screenshot testing framework:
Ta5d6ff```Ta5d6ffbash
./gradlew :screenshot-tests:updateDebugScreenshotTest T8b949e# Record golden images
./gradlew :screenshot-tests:validateDebugScreenshotTest T8b949e# Compare against goldens
./gradlew :screenshot-tests:copyDocsScreenshots T8b949e# Copy reference images to docs pipeline
Ta5d6ff```
Tc9d1d9## Test Organization
Ta5d6ff```
feature/my-feature/src/
βββ commonTest/kotlin/org/meshtastic/feature/myfeature/
β βββ MyBusinessLogicTest.kt
β βββ MyModelTest.kt
βββ jvmTest/kotlin/org/meshtastic/feature/myfeature/
βββ MyDesktopSpecificTest.kt
```
Tc9d1d9## Testing Guidelines
Tc9d1d9### DO
Tff7b72- Write tests in Ta5d6ff`commonTest` when possible (runs everywhere)
Tff7b72- Test business logic independently from UI
Tff7b72- Use fakes/stubs instead of mocks where practical
Tff7b72- Test edge cases: empty states, error states, boundary values
Tff7b72- Test deep link routing in Ta5d6ff`DeepLinkRouterTest`
Tff7b72- Keep tests fast β no network, no disk I/O in unit tests
Tc9d1d9### DON'T
Tff7b72- Don't test framework behavior (Compose internals, Room queries)
Tff7b72- Don't create tests that depend on other feature modules
Tff7b72- Don't use Ta5d6ff`Thread.sleep` β use coroutine test dispatchers
Tff7b72- Don't rely on test execution order
Tc9d1d9## Running Tests
Ta5d6ff```Ta5d6ffbash
T8b949e# All KMP tests
./gradlew allTests
T8b949e# Specific module
./gradlew :feature:docs:allTests
T8b949e# Code quality
./gradlew spotlessCheck detekt
T8b949e# Full verification
./gradlew spotlessCheck detekt kmpSmokeCompile Tffa657test allTests
Ta5d6ff```
Tc9d1d9## CI Integration
Tests run automatically on:
Tff7b72- Pull request creation/update
Tff7b72- Push to Ta5d6ff`main`
Tff7b72- Pre-release validation
The CI workflow uses Ta5d6ff`ubuntu-24.04` with JDK 21 and Gradle caching.
---
Served by rngit 1.5.0 - Generated in 0.05s